package com.phoenix.callAnalysis;

import com.phoenix.callAnalysis.models.LoadDataFlag;
import com.phoenix.callAnalysis.test.TestActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class CallAnalysisActivity extends BaseActivity {
	private static final String TAG = CallAnalysisActivity.class
			.getSimpleName();
	private Button loadDataButton;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		Log.i(TAG, "onCreate()...");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.call_analysis);

		// loadData
		loadDataButton = (Button) findViewById(R.id.loadData_button);
		loadDataButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent(CallAnalysisActivity.this,
						LoadDataActivity.class));
				finish();
			}
		});
		
		ifNeedLoadData();

		// test Button
		Button testButton = (Button) findViewById(R.id.button1);
		testButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent(CallAnalysisActivity.this,
						TestActivity.class));
				finish();
			}
		});
	}

	private void ifNeedLoadData() {
		if (CallAnalysisApplication.myCallLog.getCallsCount() != CallAnalysisApplication.myDB
				.getCallsCount()) {
			CallAnalysisApplication.needLoadData = LoadDataFlag.NEED;
		}
	}
}